package com.oa.co.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oa.co.mapper.AuserMapper;
import com.oa.co.pojo.Performance;
import com.oa.co.pojo.User;
import com.oa.co.service.AuserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("auserService")
public class AuserServiceImpl implements AuserService {

    @Autowired
    private AuserMapper auserMapper;

    @Override
    public PageInfo<User> selectUserList(Integer page, Integer limit, String username, String phone) {

        User user = new User();
        user.setUsername(username);
        user.setPhone(phone);

        if(page != null && limit != null){
            PageHelper.startPage(page,limit);
            List<User> users = auserMapper.selectUserList(user);
            PageInfo<User> pageInfo = new PageInfo<>(users);
            return pageInfo;
        }else {
            List<User> users = auserMapper.selectUserList(user);
            PageInfo<User> pageInfo = new PageInfo<>(users);
            return pageInfo;
        }
    }

    @Override
    public int auserAdd(User user) {
        return auserMapper.auserAdd(user);
    }

    @Override
    public int delauser(Integer id) {
        return auserMapper.delauser(id);
    }

    @Override
    public int editAuser(User user) {
        return auserMapper.editAuser(user);
    }

    @Override
    public int delAllAuser(List<Integer> list) {
        return auserMapper.delAllAuser(list);
    }
}
